home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks '96 / Internet Chooser / reggie / light / netstack.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-21  |  6.6 KB  |  184 lines  |  [TEXT/MMCC]

  1. /* File "netstack.cpp", Light Sockets - Copyright (C) Matt Slot, 1996         */
  2. /* Implementation wrappers for "Light Sockets" network abstraction library.   */
  3.  
  4. #include "stddebug.h"
  5. #include "stdtypes.h"
  6.  
  7. #include "netstack.h"
  8.  
  9. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  10. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  11.  
  12. NetworkStack::NetworkStack(SocketRef socket) {
  13.     this->socket = socket;
  14.     }
  15.  
  16. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  17. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  18.  
  19. NetworkStack::~NetworkStack() {
  20.  
  21.     }
  22.  
  23. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  24. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  25. #pragma mark -
  26.  
  27. SocketResult NetworkStack::DoLoad() {
  28.     return(eSocketNoError); /* Stub function, implementation in derived class */
  29.     }
  30.  
  31. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  32. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  33.  
  34. SocketResult NetworkStack::DoUnload() {
  35.     return(eSocketNoError); /* Stub function, implementation in derived class */
  36.     }
  37.  
  38. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  39. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  40. #pragma mark -
  41.  
  42. SocketResult NetworkStack::DoCreate() {
  43.     return(eSocketNoError); /* Stub function, implementation in derived class */
  44.     }
  45.  
  46. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  47. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  48.  
  49. SocketResult NetworkStack::DoTickle() {
  50.     return(eSocketNoError); /* Stub function, implementation in derived class */
  51.     }
  52.  
  53. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  54. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  55.  
  56. SocketResult NetworkStack::DoDispose() {
  57.     this->socket = 0;
  58.     return(eSocketNoError); /* Stub function, implementation in derived class */
  59.     }
  60.  
  61. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  62. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  63. #pragma mark -
  64.  
  65. SocketResult NetworkStack::DoBind(SocketAddressPtr reqAddress,
  66.         SocketAddressPtr retAddress) {
  67.     return(eSocketNoError); /* Stub function, implementation in derived class */
  68.     }
  69.  
  70. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  71. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  72.  
  73. SocketResult NetworkStack::DoUnbind() {
  74.     return(eSocketNoError); /* Stub function, implementation in derived class */
  75.     }
  76.  
  77. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  78. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  79. #pragma mark -
  80.  
  81. SocketResult NetworkStack::DoAddressResolve(Char8 *textAddress,
  82.         SocketAddressPtr socketAddress) {
  83.     return(eSocketNoError); /* Stub function, implementation in derived class */
  84.     }
  85.  
  86. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  87. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  88.  
  89. SocketResult NetworkStack::DoAddressLookup(SocketAddressPtr socketAddress,
  90.         Char8 *textAddress) {
  91.     return(eSocketNoError); /* Stub function, implementation in derived class */
  92.     }
  93.  
  94. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  95. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  96. #pragma mark -
  97.  
  98. SocketResult NetworkStack::DoDatagramWrite(Byte8 *dataPtr, UInt32 dataLen,
  99.         SocketAddressPtr address) {
  100.     SocketResult error = eSocketNoError;
  101.     
  102.     /* Implement socket callback chain */
  103.     qAssertIfFalse(qIsSocketTypeDatagram(socket->GetSocketType()), 
  104.             eSocketErrBadParam, kSocketErrBadParamStr);
  105.      
  106.     qThrowIfError(((DatagramSocketRef) socket)->CallWriteProc(dataPtr, dataLen,
  107.             address), 0);
  108.  
  109. /* CATCH */
  110.     qCatch();
  111.     return(error);
  112.     }
  113.  
  114. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  115. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  116.  
  117. SocketResult NetworkStack::DatagramRead(Byte8 *dataPtr, UInt32 dataLen,
  118.         SocketAddressPtr address) {
  119.     SocketResult error = eSocketNoError;
  120.     
  121.     /* Implement socket callback chain */
  122.     qAssertIfFalse(qIsSocketTypeDatagram(socket->GetSocketType()), 
  123.             eSocketErrBadParam, kSocketErrBadParamStr);
  124.      
  125.     qThrowIfError(((DatagramSocketRef) socket)->CallReadProc(dataPtr, dataLen,
  126.             address), 0);
  127.  
  128. /* CATCH */
  129.     qCatch();
  130.     return(error);
  131.     }
  132.  
  133. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  134. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  135. #pragma mark -
  136.  
  137. SocketResult NetworkStack::DoStreamServer(UInt32 sessions) {
  138.     return(eSocketNoError); /* Stub function, implementation in derived class */
  139.     }
  140.  
  141. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  142. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  143.  
  144. SocketResult NetworkStack::DoStreamClient(SocketAddressPtr address) {
  145.     return(eSocketNoError); /* Stub function, implementation in derived class */
  146.     }
  147.  
  148. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  149. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  150.  
  151. SocketResult NetworkStack::DoStreamWrite(Byte8 *dataPtr, UInt32 dataLen) {
  152.     return(eSocketNoError); /* Stub function, implementation in derived class */
  153.     }
  154.  
  155. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  156. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  157.  
  158. SocketResult NetworkStack::DoStreamClose(Bool8 orderly) {
  159.     return(eSocketNoError); /* Stub function, implementation in derived class */
  160.     }
  161.  
  162. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  163. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  164.  
  165. SocketResult NetworkStack::StreamAccept(SocketRef *newSocket,
  166.         SocketAddressPtr address) {
  167.     return(eSocketNoError);
  168.     }
  169.  
  170. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  171. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  172.  
  173. SocketResult NetworkStack::StreamRead(Byte8 *dataPtr, UInt32 dataLen) {
  174.     return(eSocketNoError);
  175.     }
  176.  
  177. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  178. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  179.  
  180. SocketResult NetworkStack::StreamClosing(Bool8 orderly) {
  181.     return(eSocketNoError);
  182.     }
  183.  
  184.